<html xmlns:th="http://www.thymeleaf.org" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <meta name="description" content="Bootstrap Admin App + jQuery"/>
    <meta name="keywords" content="app, responsive, jquery, bootstrap, dashboard, admin"/>
    <title>库存管理系统</title>
    <script type="text/javascript" th:src="@{/js/jquery-1.11.3.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/security.js}"></script>
    <link rel="stylesheet" th:href="@{/css/login/ie_cas.css}"></link>
    <link rel="stylesheet" th:href="@{/css/login/cas.css}"></link>
</head>
<body>
<div  >
    <form id="form"  method="post" onsubmit="return validateForm();">
        <div class="box">
            <div id="login_gmcc">
                <div id="container">
                    <div id="content">
                        <table cellpadding="0" cellspacing="0">
                            <tr>
                                <th>
                                    帐号:
                                </th>
                                <td>
                                    <input type="text" id="username" name="username" />

                                </td>

                            </tr>
                            <tr>
                                <th>
                                    密码:
                                </th>
                                <td>
                                    <input type="password" id="password"  auto="true" autocomplete="off" />
                                </td>
                            </tr>
                            <tfoot>
                            <tr>
                                <th>
                                </th>
                                <td>
                                    <button  type="submit" class="login_button"> </button>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" id="errors">
                                    <div id="errorMsg"  style="display:none; " class="alert alert-danger text-center"></div>
                                </td>
                            </tr>
                            </tfoot>
                        </table>

                    </div>
                    <div id="footer">
                        &copy;2018 广州凯因科技有限公司
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
</body>
<script type='text/javascript'>
    function validateForm(){
        if($('#username').val()==""||$('#password').val()=="") {
            $("#errorMsg").html("请输入账号密码");
            $("#errorMsg").show();
        }else {
            var datas={
                name: $('#username').val(),
                password: $('#password').val()
            };
            $.ajax({
                url: "/user/login",
                data: datas,
                method: "post",
                contentType: "application/x-www-form-urlencoded",
                dataType: "json",
                success: function (data) {
                    if(data.rspCode == '000000'){
                        window.open(data.data, '_self');
                    }else{
                        $("#errorMsg").html(data.rspMsg);
                        $("#errorMsg").show();
                    }
                }
            });

        }
        return false;
    }

</script>
</html>